﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Web.Login" %>

<!DOCTYPE html>

<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>登录</title>

    <link href="css/bootstrap.min.css" rel="stylesheet" />

    
    <link href="css/font-awesome.min.css" rel="stylesheet" />
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if (window.top !== window.self) { window.top.location = window.location; }</script>
    
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <h1 class="logo-name" style="width:100%;"></h1>
        <div class=" align-self-center">

            <h3>系统登录</h3>
            <div class="m-t">
                  <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <input type="text" class="form-control" id="Account" name="uname" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" id="Password" name="upwd" placeholder="密码" required="">
                </div>

                <div class="form-group ">
                   
                        <select class="form-control" name="role" id="role">
                            <option value="0">请选择</option>
                             <%foreach (var items in rlist) %>
                               <%{ %>
                                    <option value="<%=items.Id %>"><%=items.name %></option>
                              <% } %>
                           
                           
                        </select>
                  
                 
                </div>
                <div style="clear:both"></div>
                <button type="button" id="sub" class="btn btn-primary block full-width m-b" >登 录</button>
            </div>
          

              


                

      
        </div>

    </div>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <script src="js/plugins/iCheck/icheck.min.js"></script>

    <script>
        function Login(Account, Password,Role, callback) {
            $.ajax({
                type: 'post',
                url: '../Hanlder/UserHanlder.ashx?Method=Login',
                data: { Password: Password, Account: Account, Role: Role },
                success: function (data) {
                    callback(data);
                }
            });
        }
        $(document).ready(function () {
            $("#sub").click(function () {
                var Password = $("#Password").val();
                var Account = $("#Account").val();
                var Role = $("#role").val();
                Login(Account, Password,Role, function (res) {
                    if (res === 'true') {
                        location.href = 'index.aspx';
                    } else {
                        alert('账号或者密码错误');
                    }
                })
            });
        });
    </script>
        
    
</body>

</html>
